var res [][]int

func subsets(nums []int) [][]int {
    res = make([][]int, 0)
    backTracking(nums, 0 , []int{})
    return res
}

func backTracking(nums []int, startIndex int, path []int) {
    tem := make([]int, len(path))
    copy(tem, path)
    res = append(res, tem)
    if startIndex >= len(nums) {
        return
    }
    for i:=startIndex; i<len(nums); i++ {
        path = append(path, nums[i])
        backTracking(nums, i+1, path)
        path = path[:len(path)-1]
    }
}